/*
 * @Description: main
 * @Author:
 * @Date: 2018-05-31 11:49:33
 * @Copyright: Created by Panxsoft.
 */
import Vue from 'vue';
import iView from 'iview';
import VueRouter from 'vue-router';
import axios from 'src/utils/axios-interceptors';

// import { resizeModal } from 'src/utils/utils';	// 调整模态框右边居中的

import { i18n } from 'src/i18n/index';
import router from './router';
import store from './vuex/store';
import App from './app.vue';

/* eslint-disable  */
import 'iview/dist/styles/iview.css';
import 'src/assets/css/common.css';
/* eslint-enable  */
// import faker from 'faker';

import * as Sentry from '@sentry/browser';
import * as Integrations from '@sentry/integrations';

Vue.use(VueRouter);
// Vue.use(iviewArea);

/**
 *  覆盖iview的i18nHandler方法
 *  @see https://github.com/iview/iview/issues/1090
 */
Vue.use(iView, {
	i18n(path, options) {
		const value = i18n.t(path, options);
		if (value !== null && value !== undefined) return value;
		return '';
	},
});

Vue.prototype.$http = axios;

// Vue.prototype.resizeModal = resizeModal;	// 将调整模态框位置的函数存到vue的prototype里面，方便调用

function initProject() {
	return new Vue({
		el: '#app',
		i18n,
		router,
		store,
		render: h => h(App),
	});
}

initProject();

if (process.env.NODE_ENV === 'production') {
	Sentry.init({
		dsn: 'https://59bba888e5e7416f822d78e793d07380@sentry.panxsoft.com/11',
		integrations: [new Integrations.Vue({ Vue, attachProps: true })],
		release: 'test@1.0.2',
		logErrors: true,
	});
}
